﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMaster.Master" AutoEventWireup="true" CodeBehind="lugares.aspx.cs" Inherits="TrangestAdmin.Lugares" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <article class="module width_full">
        <header>
            <h3 class="tabs_involved">
                Lugares
            </h3>
        </header>
        <div class="tab_container">
            <fieldset>
                <legend>Tabla Lugares</legend>
                <table>
                    <tr>
                        <td>
                            Filtrar Descripcion:
                        </td>
                        <td>
                            <asp:TextBox ID="uxFiltro" runat="server" Text="" AutoPostBack="true" OnTextChanged="uxFiltro_TextChanged"></asp:TextBox>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
                <table>
                    <tr>
                        <td>
                            <asp:GridView ID="uxTablaLugares" runat="server" AutoGenerateColumns="False" DataKeyNames="id_lugar"
                                DataSourceID="sqllugares" CssClass="tablesorter" AllowPaging="True" AllowSorting="True"
                                PageSize="12" onrowcancelingedit="uxTablaLugares_RowCancelingEdit" 
                                onrowediting="uxTablaLugares_RowEditing" 
                                onrowupdating="uxTablaLugares_RowUpdating" 
                                onrowdatabound="uxTablaLugares_RowDataBound" 
                                onrowdeleting="uxTablaLugares_RowDeleting">
                                <AlternatingRowStyle CssClass="tablesorter_alt" />
                                <Columns>
                                    <asp:CommandField ShowEditButton="True" UpdateImageUrl="images/icn_alert_success.png"
                                        EditImageUrl="images/icn_edit.png" DeleteImageUrl="images/icn_trash.png" ButtonType="Image"
                                        CancelImageUrl="images/icn_alert_error.png" />
                                    <asp:BoundField DataField="id_lugar" HeaderText="id_lugar" InsertVisible="False"
                                        ReadOnly="True" SortExpression="id_lugar" Visible="false"/>
                                    <asp:BoundField DataField="descripcion" HeaderText="descripcion" SortExpression="descripcion" ControlStyle-Width="300px" />
                                    <asp:TemplateField>                                        
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnDelete" AlternateText="Delete" ImageUrl="~/images/icn_trash.png" runat="server" OnClientClick="return confirm('Está seguro de eliminar esta fila?');" CommandName="Delete" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <HeaderStyle CssClass="tableHeader" />
                            </asp:GridView>
                        </td>
                    </tr>
                </table>
            </fieldset>
            <fieldset>
                <legend>Nuevo Lugar</legend>
                <table>
                    <tr>
                        <td style="text-align: right;">
                            Descripcion:
                        </td>
                        <td>
                            <asp:TextBox ID="uxNewDescripcion" runat="server" Text=""></asp:TextBox>
                        </td>
                        <td style="text-align: right;">
                            
                        </td>
                        <td>
                            
                        </td>
                        <td style="text-align: right;">
                            
                        </td>
                        <td>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                        </td>
                        <td>
                            <asp:Button ID="uxInsertNew" runat="server" Text="Insertar" 
                                onclick="uxInsertNew_Click" />
                        </td>
                    </tr>
                </table>
            </fieldset>
        </div>
    </article>
    <asp:SqlDataSource ID="sqllugares" runat="server" ConnectionString="<%$ ConnectionStrings:trangestConnectionString %>"
        ProviderName="<%$ ConnectionStrings:trangestConnectionString.ProviderName %>"
        SelectCommand="SELECT * FROM lugares ORDER BY id_lugar;" 
        UpdateCommand="UPDATE    lugares
SET              descripcion = :descripcion
WHERE     id_lugar = :id_lugar;"
        DeleteCommand="DELETE FROM lugares WHERE id_lugar = :id_lugar;"
        InsertCommand="INSERT INTO lugares (descripcion) 
        VALUES ( @descripcion);">
    <UpdateParameters>
        <asp:Parameter Name="descripcion" DbType="String" />
    </UpdateParameters>
    <InsertParameters>
        <asp:ControlParameter Name="descripcion" DbType="String" ControlID="uxNewDescripcion" PropertyName="Text" DefaultValue="" />
    </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>
